package org.springframework.boot.dcj.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Component;

@Component
public class CommonService {

    @SentinelResource(value = "sentinelResourceAspect", fallback = "fallback", blockHandler = "blockHandler")
    public String sentinelResourceAspect() {
        return "sentinelResourceAspect";
    }

    // 限流与阻塞处理
    public String blockHandler(BlockException ex) {
        return "限流了";
    }
    // 熔断处理
    public String fallback() {
        return "熔断了";
    }
}
